package com.gopay.scheduler.job;

import com.gopay.common.constants.fund.FundFileSourceConstants;
import com.gopay.common.domain.fund.vo.FileBizParam;
import com.gopay.common.util.DateUtils;
import com.gopay.common.util.FastJsonUtil;
import com.gopay.common.util.LogUtil;
import com.gopay.cps.service.FileHandlerService;
import com.gopay.scheduler.GopayBaseJob;
import com.gopay.scheduler.service.fund.FundBaseOperateService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import javax.annotation.Resource;
import java.util.Date;

/**
 * 基金转国付宝做账02018
 * @author baiyunpeng
 * @2016年7月14日 下午3:36:05  www.gopay.com.cn Inc.All rights reserved.
 */
public class Fund2GopayTransMoneyJob extends GopayBaseJob {
    private Logger logger = LoggerFactory.getLogger(this.getClass());
    @Resource(name = "fileHandlerService")
    private FileHandlerService fundFileRemoteService;
    @Autowired
    private FundBaseOperateService operateService;

    @Override
    protected void doJobInternal() {
        try {
            String settleDay = DateUtils.format(new Date(), "yyyyMMdd");
            LogUtil.info(logger,"【基金转国付宝转账】开始，清算日期：%s",settleDay);

            FileBizParam fileBizParam = new FileBizParam(settleDay, operateService.queryAllFundCorp(), FundFileSourceConstants.CORN);
            fileBizParam.setCheckNotify(true);
            LogUtil.info(logger, "【基金转国付宝转账】传入指令：%s", FastJsonUtil.toJSONString(fileBizParam));
            String res = fundFileRemoteService.fund2GopayTransferMoney(fileBizParam);
            LogUtil.info(logger,"【基金转国付宝转账】结束，返回结果：%s",res);
        } catch (Exception e) {
            LogUtil.error(logger,e,"【基金转国付宝转账】异常");
        }
    }
}
